home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 1.iso
/
toolbox
/
src
/
exampleCode
/
opengl
/
bench
/
immediate.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-11-11
|
12KB
|
493 lines
/*
* Copyright (C) 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* dinomometer - a synthetic modeling benchmark for OpenGL
* by Mark Kilgard
* Silicon Graphics Inc.
* November 15, 1993
* $Revision: 1.1 $
* code for immediate mode rendering of the dinosaur model
*/
#undef NORMAL3F
#undef FUNC
#ifdef DoLighting
#define NORMAL3F(x,y,z) glNormal3f(x, y, z)
#define FUNC(name) name
#else
#define NORMAL3F(x,y,z)
#define FUNC(name) name##NoLite
#endif
void
FUNC(renderBodySide)(void)
{
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
glVertex2f(8, 12);
glVertex2f(7, 15);
glVertex2f(7, 13);
glVertex2f(8, 16);
glVertex2f(7, 15);
glVertex2f(8, 12);
glVertex2f(11, 5);
glVertex2f(10, 13.5);
glVertex2f(10, 4);
glVertex2f(11, 11.5);
glVertex2f(10, 13.5);
glVertex2f(11, 5);
glVertex2f(13, 12);
glVertex2f(10, 13.5);
glVertex2f(11, 11.5);
glVertex2f(13, 13);
glVertex2f(10, 13.5);
glVertex2f(13, 12);
glVertex2f(1, 2);
glVertex2f(0, 3);
glVertex2f(1, 1);
glVertex2f(3, 2);
glVertex2f(1, 2);
glVertex2f(1, 1);
glEnd();
glBegin(GL_TRIANGLE_FAN);
glVertex2f(5, 1);
glVertex2f(4, 3);
glVertex2f(3, 2);
glVertex2f(1, 1);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(6, 6);
glVertex2f(4, 3);
glVertex2f(5, 1);
glVertex2f(7, 11);
glVertex2f(6, 6);
glVertex2f(5, 1);
glVertex2f(8, 4);
glVertex2f(7, 11);
glVertex2f(5, 1);
glVertex2f(8, 12);
glVertex2f(7, 11);
glVertex2f(8, 4);
glVertex2f(8, 16);
glVertex2f(8, 12);
glVertex2f(8, 4);
glVertex2f(10, 4);
glVertex2f(8, 16);
glVertex2f(8, 4);
glVertex2f(10, 13.5);
glVertex2f(8, 16);
glVertex2f(10, 4);
glVertex2f(11, 16);
glVertex2f(8, 16);
glVertex2f(10, 13.5);
glVertex2f(13, 14);
glVertex2f(11, 16);
glVertex2f(10, 13.5);
glVertex2f(13, 15);
glVertex2f(11, 16);
glVertex2f(13, 14);
glEnd();
}
void
FUNC(renderBody)(void)
{
if(backcull) glFrontFace(GL_CW);
glShadeModel(GL_FLAT);
glBegin(GL_QUAD_STRIP);
glVertex3f(0, 3, 0);
NORMAL3F(-0.894427, -0.447214, 0);
glVertex3f(0, 3, 3);
glVertex3f(1, 1, 0);
NORMAL3F(0, -1, 0);
glVertex3f(1, 1, 3);
glVertex3f(5, 1, 0);
NORMAL3F(0.707107, -0.707107, 0);
glVertex3f(5, 1, 3);
glVertex3f(8, 4, 0);
NORMAL3F(0, -1, 0);
glVertex3f(8, 4, 3);
glVertex3f(10, 4, 0);
NORMAL3F(0.707107, -0.707107, 0);
glVertex3f(10, 4, 3);
glVertex3f(11, 5, 0);
NORMAL3F(1, 0, 0);
glVertex3f(11, 5, 3);
glVertex3f(11, 11.5, 0);
NORMAL3F(0.242536, -0.970143, 0);
glVertex3f(11, 11.5, 3);
glVertex3f(13, 12, 0);
NORMAL3F(1, 0, 0);
glVertex3f(13, 12, 3);
glVertex3f(13, 13, 0);
NORMAL3F(0.164399, 0.986394, 0);
glVertex3f(13, 13, 3);
glVertex3f(10, 13.5, 0);
NORMAL3F(0.164399, -0.986394, 0);
glVertex3f(10, 13.5, 3);
glVertex3f(13, 14, 0);
NORMAL3F(1, 0, 0);
glVertex3f(13, 14, 3);
glVertex3f(13, 15, 0);
NORMAL3F(0.447214, 0.894427, 0);
glVertex3f(13, 15, 3);
glVertex3f(11, 16, 0);
NORMAL3F(0, 1, 0);
glVertex3f(11, 16, 3);
glVertex3f(8, 16, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(8, 16, 3);
glVertex3f(7, 15, 0);
NORMAL3F(-1, 0, 0);
glVertex3f(7, 15, 3);
glVertex3f(7, 13, 0);
NORMAL3F(-0.707107, -0.707107, 0);
glVertex3f(7, 13, 3);
glVertex3f(8, 12, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(8, 12, 3);
glVertex3f(7, 11, 0);
NORMAL3F(-0.980581, 0.196116, 0);
glVertex3f(7, 11, 3);
glVertex3f(6, 6, 0);
NORMAL3F(-0.83205, 0.5547, 0);
glVertex3f(6, 6, 3);
glVertex3f(4, 3, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(4, 3, 3);
glVertex3f(3, 2, 0);
NORMAL3F(0, 1, 0);
glVertex3f(3, 2, 3);
glVertex3f(1, 2, 0);
NORMAL3F(0.707107, 0.707107, 0);
glVertex3f(1, 2, 3);
glVertex3f(0, 3, 0);
NORMAL3F(-0.894427, -0.447214, 0);
glVertex3f(0, 3, 3);
glEnd();
NORMAL3F(0.0, 0.0, -1.0);
FUNC(renderBodySide)();
glPushMatrix();
glTranslatef(0, 0, 3);
if(backcull) glFrontFace(GL_CCW);
NORMAL3F(0.0, 0.0, 1.0);
FUNC(renderBodySide)();
glPopMatrix();
}
void
FUNC(renderArmSide)(void)
{
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
glVertex2f(15, 10);
glVertex2f(14.5, 10);
glVertex2f(15, 9.5);
glVertex2f(15.5, 11);
glVertex2f(14.5, 10);
glVertex2f(15, 10);
glVertex2f(9, 11);
glVertex2f(8, 10);
glVertex2f(9, 9);
glVertex2f(10, 9);
glVertex2f(9, 11);
glVertex2f(9, 9);
glVertex2f(11, 11);
glVertex2f(9, 11);
glVertex2f(10, 9);
glVertex2f(13, 8);
glVertex2f(11, 11);
glVertex2f(10, 9);
glVertex2f(13, 9);
glVertex2f(11, 11);
glVertex2f(13, 8);
glVertex2f(14, 9);
glVertex2f(13, 9);
glVertex2f(13, 8);
glVertex2f(14, 10);
glVertex2f(13, 9);
glVertex2f(14, 9);
glVertex2f(14, 11);
glVertex2f(14, 10);
glVertex2f(14, 9);
glVertex2f(14.5, 10);
glVertex2f(14, 11);
glVertex2f(14, 9);
glVertex2f(15, 9.5);
glVertex2f(14.5, 10);
glVertex2f(14, 9);
glVertex2f(16, 9);
glVertex2f(15, 9.5);
glVertex2f(14, 9);
glVertex2f(16, 10);
glVertex2f(15, 10);
glVertex2f(15, 9.5);
glEnd();
}
void
FUNC(renderArm)(void)
{
if(backcull) glFrontFace(GL_CW);
glShadeModel(GL_FLAT);
glBegin(GL_QUAD_STRIP);
glVertex3f(8, 10, 0);
NORMAL3F(-0.707107, -0.707107, 0);
glVertex3f(8, 10, 0.75);
glVertex3f(9, 9, 0);
NORMAL3F(0, -1, 0);
glVertex3f(9, 9, 0.75);
glVertex3f(10, 9, 0);
NORMAL3F(-0.316228, -0.948683, 0);
glVertex3f(10, 9, 0.75);
glVertex3f(13, 8, 0);
NORMAL3F(0.707107, -0.707107, 0);
glVertex3f(13, 8, 0.75);
glVertex3f(14, 9, 0);
NORMAL3F(0, -1, 0);
glVertex3f(14, 9, 0.75);
glVertex3f(16, 9, 0);
NORMAL3F(0.447214, 0.894427, 0);
glVertex3f(16, 9, 0.75);
glVertex3f(15, 9.5, 0);
NORMAL3F(0.447214, -0.894427, 0);
glVertex3f(15, 9.5, 0.75);
glVertex3f(16, 10, 0);
NORMAL3F(0, 1, 0);
glVertex3f(16, 10, 0.75);
glVertex3f(15, 10, 0);
NORMAL3F(0.894427, -0.447214, 0);
glVertex3f(15, 10, 0.75);
glVertex3f(15.5, 11, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(15.5, 11, 0.75);
glVertex3f(14.5, 10, 0);
NORMAL3F(0.894427, 0.447214, 0);
glVertex3f(14.5, 10, 0.75);
glVertex3f(14, 11, 0);
NORMAL3F(-1, 0, 0);
glVertex3f(14, 11, 0.75);
glVertex3f(14, 10, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(14, 10, 0.75);
glVertex3f(13, 9, 0);
NORMAL3F(0.707107, 0.707107, 0);
glVertex3f(13, 9, 0.75);
glVertex3f(11, 11, 0);
NORMAL3F(0, 1, 0);
glVertex3f(11, 11, 0.75);
glVertex3f(9, 11, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(9, 11, 0.75);
glVertex3f(8, 10, 0);
NORMAL3F(-0.707107, -0.707107, 0);
glVertex3f(8, 10, 0.75);
glEnd();
NORMAL3F(0.0, 0.0, -1.0);
FUNC(renderArmSide)();
glPushMatrix();
glTranslatef(0, 0, 0.75);
if(backcull) glFrontFace(GL_CCW);
NORMAL3F(0.0, 0.0, 1.0);
FUNC(renderArmSide)();
glPopMatrix();
}
void
FUNC(renderLegSide)(void)
{
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
glVertex2f(9, 3);
glVertex2f(8, 6);
glVertex2f(8, 4);
glVertex2f(9, 7);
glVertex2f(8, 6);
glVertex2f(9, 3);
glVertex2f(9, 0);
glVertex2f(8, 1);
glVertex2f(8, 0.5);
glVertex2f(9, 2);
glVertex2f(8, 1);
glVertex2f(9, 0);
glVertex2f(9, 3);
glVertex2f(9, 2);
glVertex2f(9, 0);
glVertex2f(9, 7);
glVertex2f(9, 3);
glVertex2f(9, 0);
glVertex2f(10, 1);
glVertex2f(9, 7);
glVertex2f(9, 0);
glVertex2f(12, 0);
glVertex2f(10, 1);
glVertex2f(9, 0);
glVertex2f(10, 2);
glVertex2f(9, 7);
glVertex2f(10, 1);
glVertex2f(10, 7);
glVertex2f(9, 7);
glVertex2f(10, 2);
glVertex2f(11, 6);
glVertex2f(10, 7);
glVertex2f(10, 2);
glVertex2f(12, 4);
glVertex2f(11, 6);
glVertex2f(10, 2);
glEnd();
}
void
FUNC(renderLeg)(void)
{
if(backcull) glFrontFace(GL_CW);
glShadeModel(GL_FLAT);
glBegin(GL_QUAD_STRIP);
glVertex3f(8, 6, 0);
NORMAL3F(-1, 0, 0);
glVertex3f(8, 6, 1.5);
glVertex3f(8, 4, 0);
NORMAL3F(-0.707107, -0.707107, 0);
glVertex3f(8, 4, 1.5);
glVertex3f(9, 3, 0);
NORMAL3F(-1, 0, 0);
glVertex3f(9, 3, 1.5);
glVertex3f(9, 2, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(9, 2, 1.5);
glVertex3f(8, 1, 0);
NORMAL3F(-1, 0, 0);
glVertex3f(8, 1, 1.5);
glVertex3f(8, 0.5, 0);
NORMAL3F(-0.447214, -0.894427, 0);
glVertex3f(8, 0.5, 1.5);
glVertex3f(9, 0, 0);
NORMAL3F(0, -1, 0);
glVertex3f(9, 0, 1.5);
glVertex3f(12, 0, 0);
NORMAL3F(0.447214, 0.894427, 0);
glVertex3f(12, 0, 1.5);
glVertex3f(10, 1, 0);
NORMAL3F(1, 0, 0);
glVertex3f(10, 1, 1.5);
glVertex3f(10, 2, 0);
NORMAL3F(0.707107, -0.707107, 0);
glVertex3f(10, 2, 1.5);
glVertex3f(12, 4, 0);
NORMAL3F(0.894427, 0.447214, 0);
glVertex3f(12, 4, 1.5);
glVertex3f(11, 6, 0);
NORMAL3F(0.707107, 0.707107, 0);
glVertex3f(11, 6, 1.5);
glVertex3f(10, 7, 0);
NORMAL3F(0, 1, 0);
glVertex3f(10, 7, 1.5);
glVertex3f(9, 7, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(9, 7, 1.5);
glVertex3f(8, 6, 0);
NORMAL3F(-1, 0, 0);
glVertex3f(8, 6, 1.5);
glEnd();
NORMAL3F(0.0, 0.0, -1.0);
FUNC(renderLegSide)();
glPushMatrix();
glTranslatef(0, 0, 1.5);
if(backcull) glFrontFace(GL_CCW);
NORMAL3F(0.0, 0.0, 1.0);
FUNC(renderLegSide)();
glPopMatrix();
}
void
FUNC(renderEyeSide)(void)
{
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
glVertex2f(9, 15.25);
glVertex2f(8.75, 15);
glVertex2f(9, 14.7);
glVertex2f(9.6, 14.7);
glVertex2f(9, 15.25);
glVertex2f(9, 14.7);
glVertex2f(9.6, 15.25);
glVertex2f(9, 15.25);
glVertex2f(9.6, 14.7);
glVertex2f(10.1, 15);
glVertex2f(9.6, 15.25);
glVertex2f(9.6, 14.7);
glEnd();
}
void
FUNC(renderEye)(void)
{
if(backcull) glFrontFace(GL_CW);
glShadeModel(GL_FLAT);
glBegin(GL_QUAD_STRIP);
glVertex3f(8.75, 15, 0);
NORMAL3F(-0.768221, -0.640184, 0);
glVertex3f(8.75, 15, 3.2);
glVertex3f(9, 14.7, 0);
NORMAL3F(0, -1, 0);
glVertex3f(9, 14.7, 3.2);
glVertex3f(9.6, 14.7, 0);
NORMAL3F(0.514496, -0.857493, 0);
glVertex3f(9.6, 14.7, 3.2);
glVertex3f(10.1, 15, 0);
NORMAL3F(0.447214, 0.894427, 0);
glVertex3f(10.1, 15, 3.2);
glVertex3f(9.6, 15.25, 0);
NORMAL3F(0, 1, 0);
glVertex3f(9.6, 15.25, 3.2);
glVertex3f(9, 15.25, 0);
NORMAL3F(-0.707107, 0.707107, 0);
glVertex3f(9, 15.25, 3.2);
glVertex3f(8.75, 15, 0);
NORMAL3F(-0.768221, -0.640184, 0);
glVertex3f(8.75, 15, 3.2);
glEnd();
NORMAL3F(0.0, 0.0, -1.0);
FUNC(renderEyeSide)();
glPushMatrix();
glTranslatef(0, 0, 3.2);
if(backcull) glFrontFace(GL_CCW);
NORMAL3F(0.0, 0.0, 1.0);
FUNC(renderEyeSide)();
glPopMatrix();
}
void
FUNC(renderDinosaur)(void)
{
glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor);
FUNC(renderBody)();
glPushMatrix();
glTranslatef(0, 0, 3);
FUNC(renderArm)();
FUNC(renderLeg)();
glTranslatef(0, 0, -3.75);
FUNC(renderArm)();
glTranslatef(0, 0, -0.75);
FUNC(renderLeg)();
glTranslatef(0, 0, 1.4);
glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor);
FUNC(renderEye)();
glPopMatrix();
}